package com.va1m.demo.controller;

import com.va1m.demo.common.Result;
import com.va1m.demo.service.RecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 消费记录的controller
 * @author Admin
 */
@Controller
@RequestMapping("/api/record")
public class RecordController {

    @Autowired
    RecordService recordService;

    /**
     * 前往消费记录页面
     * @return
     */
    @GetMapping("/index")
    public String returnRecordIndex(){
        return "consumption";
    }

    /**
     * 获取消费记录列表
     * @param userId
     * @return
     */
    @ResponseBody
    @GetMapping("/getRecordList")
    public Result getRecordList(@RequestParam("userId") Integer userId){
        return Result.ok(recordService.getRecordList(userId));
    }

}
